 

package com.zdkj.subway.stm.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.common.core.util.R;
import com.zdkj.common.log.annotation.SysLog;
import com.zdkj.subway.stm.entity.SwStPackageTailboxManageDetail;
import com.zdkj.subway.stm.service.SwStPackageTailboxManageDetailService;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 库包/尾箱管理明细表
 *
 * @author chenbo
 * @date 2020-01-31 18:34:45
 */
@RestController
@AllArgsConstructor
@RequestMapping("/swstpackagetailboxmanagedetail" )
@Api(value = "swstpackagetailboxmanagedetail", tags = "库包/尾箱管理明细表管理")
public class SwStPackageTailboxManageDetailController {

    private final  SwStPackageTailboxManageDetailService swStPackageTailboxManageDetailService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param swStPackageTailboxManageDetail 库包/尾箱管理明细表
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    public R getSwStPackageTailboxManageDetailPage(Page page, SwStPackageTailboxManageDetail swStPackageTailboxManageDetail) {
        return R.ok(swStPackageTailboxManageDetailService.page(page, Wrappers.query(swStPackageTailboxManageDetail)));
    }


    /**
     * 通过id查询库包/尾箱管理明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public R getById(@PathVariable("id" ) Integer id) {
        return R.ok(swStPackageTailboxManageDetailService.getById(id));
    }

    /**
     * 新增库包/尾箱管理明细表
     * @param swStPackageTailboxManageDetail 库包/尾箱管理明细表
     * @return R
     */
    @ApiOperation(value = "新增库包/尾箱管理明细表", notes = "新增库包/尾箱管理明细表")
    @SysLog("新增库包/尾箱管理明细表" )
    @PostMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_package_tailbox_manage_detail_add')" )
    public R save(@RequestBody SwStPackageTailboxManageDetail swStPackageTailboxManageDetail) {
        return R.ok(swStPackageTailboxManageDetailService.save(swStPackageTailboxManageDetail));
    }

    /**
     * 修改库包/尾箱管理明细表
     * @param swStPackageTailboxManageDetail 库包/尾箱管理明细表
     * @return R
     */
    @ApiOperation(value = "修改库包/尾箱管理明细表", notes = "修改库包/尾箱管理明细表")
    @SysLog("修改库包/尾箱管理明细表" )
    @PutMapping
    @PreAuthorize("@pms.hasPermission('stm_sw_st_package_tailbox_manage_detail_edit')" )
    public R updateById(@RequestBody SwStPackageTailboxManageDetail swStPackageTailboxManageDetail) {
        return R.ok(swStPackageTailboxManageDetailService.updateById(swStPackageTailboxManageDetail));
    }

    /**
     * 通过id删除库包/尾箱管理明细表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除库包/尾箱管理明细表", notes = "通过id删除库包/尾箱管理明细表")
    @SysLog("通过id删除库包/尾箱管理明细表" )
    @DeleteMapping("/{id}" )
    @PreAuthorize("@pms.hasPermission('stm_sw_st_package_tailbox_manage_detail_del')" )
    public R removeById(@PathVariable Integer id) {
        return R.ok(swStPackageTailboxManageDetailService.removeById(id));
    }

}
